<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="css/commons.css" type=text/css  rel="stylesheet">
</head>
<body onselectstart="return false">
<div class="mall2">
    <div class="home">
        <div class="jihuo-logo jihuo-logo1">
            <img src="images/logo_in.png">
        </div>
        <div class="jihuo-center">
            <h6 class="jihuo-title">此 Microsoft Office 尚未激活</h6>
            <p>要使您安装的 Office 程序正常使用，需要完成登录后获取正版激活码</p>
            <p>否则，Office 中的大多数功能会被禁用，同时计算机和文档数据也将面临安全风险<span>(包括病毒)</span>。</p>
        </div>
        <div class="jihuo-login login-show" id="tab-1">
            <div class="jihuo-bottom" id="login_ewm">
            </div>
            <img src="images/icon.png" class="jihuo-icon">
            <img src="images/btn_loading_pic.png" class="login-again">
            <p>微信扫码登录</p>
        </div>

        <div class="jihuo-all">
            <h6>激活 Office 的优势</h6>
            <p>&bull; 免费获得价值至少<span class="money">￥480</span>/年的云存储空间(1TB)</p>
            <p>&bull; 实时保护数据安全</p>
            <p>&bull; 使用更多炫酷功能，办公更高效</p>
        </div>
        <input type="hidden" name="loginPage" value="loginPage" id="fagepage">

    </div>
</div>
    <script src="js/jquery.min.js"></script>
    <script>
       var createewm='http://officeplus.zhuazi.com/office/Weixin/createewm' ;
       var loginStatus='http://officeplus.zhuazi.com/office/Weixin/loginStatus';
       var sendEmailCode='http://officeplus.zhuazi.com/office/code/sendEmailCode';
       var user='http://officeplus.zhuazi.com/office/user/login';
       var log='http://officeplus.zhuazi.com/office/log/log/';

        var token;
        var scene_id;
        var xmlHttp;
        var channel;
        var edition;
        var sys;
        var cpuid;
        var main;
        window.onload=function (){
            window.external.GetLoginMsg();
        };
        function getLog (obj2,obj3,obj4,obj5){
            channel=obj2;
            edition=obj3;
            sys=obj4;
            cpuid=obj5;
            main=$("#fagepage").val();
            tab(main,true)
        }
        function Ajax(type, url, data, success, failed){
            // 创建ajax对象
            var xhr = null;
            if(window.XMLHttpRequest){
                xhr = new XMLHttpRequest();
            } else {
                xhr = new ActiveXObject('Microsoft.XMLHTTP')
            }

            var type = type.toUpperCase();
            // 用于清除缓存
            var random = Math.random();

            if(typeof data == 'object'){
                var str = '';
                for(var key in data){
                    str += key+'='+data[key]+'&';
                }
                data = str.replace(/&$/, '');
            }

            if(type == 'GET'){
                if(data){
                    xhr.open('GET', url + '?' + data, true);
                } else {
                    xhr.open('GET', url + '?t=' + random, true);
                }
                xhr.send();

            } else if(type == 'POST'){
                xhr.open('POST', url, true);
                xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                xhr.send(data);
            }

            // 处理返回数据
            xhr.onreadystatechange = function(){
                if(xhr.readyState == 4){
                    if(xhr.status == 200){
                        success(xhr.responseText);
                    } else {
                        if(failed){
                            failed(xhr.status);
                        }
                    }
                }
            }
        }
/*获取二维码*/
        getEwm();
        function getEwm(){
            var sendData = {};
            Ajax('post',createewm , sendData, function(data){
                var jsons = data;
                var res;
                if (typeof(JSON) == 'undefined'){
                    res = eval("("+jsons+")");
                }else {
                    res = JSON.parse(jsons);
                }
                if(res.code==200){
                    var login_ewm= document.getElementById("login_ewm");
                    if(login_ewm.hasChildNodes())
                    {
                        login_ewm.removeChild(login_ewm.firstChild);
                    };
                    var img = document.createElement("img");
                    img.src =res.data.url;
                    login_ewm.appendChild(img);
                    settime();
                    scene_id =res.data.scene_id;
                    if(scene_id !=null){
                        status()
                    }
                }

            }, function(error){

            });
        }

        var interval;
        function status(){
            interval = setInterval(fun1,2000)
        }
        /*定时器*/
        fun1=function () {
            var loginData = {scene_id:scene_id};
            clearInterval(interval);
            Ajax('post',loginStatus , loginData, function(data){
                var jsons = data;
                var res;
                if (typeof(JSON) == 'undefined'){
                    res = eval("("+jsons+")");
                }else {
                    res = JSON.parse(jsons);
                }
                if(res.code==200){
                    token=res.data.token;
                    tab("QrCodeLoginSucceed",true);
                    window.location.href='success.html';
                    window.external.LoginSuccess(token);
                    clearInterval(interval);
                }else{
                    interval = setInterval(fun1,2000)
                }

            }, function(error){

            });
        };
        var countdown=900;
        var sttime;
        function settime() {
            if (countdown == 0) {
                countdown = 900;
                $(".login-again").show();
                clearInterval(interval);
            } else {
                countdown--;
                sttime = setTimeout(function() {
                    settime();
                },1000)
            }
        }
        $(".login-again").click(function (){
            $(this).hide();
            $(".login_loading").show();
            getEwm();
        });
        /*页面显示日志*/

        function tab(name,boolen){
            $.ajax({
                type:'GET',
                url:log+ name+'/'+ channel+'/'+ edition + '/'+sys+'/'+cpuid,
                dataType: 'json',
                async:boolen,
                success:function(res) {
                    if(res.code==200){

                    }
                },
                error:function(err) {

                }
            });
        }
document.oncontextmenu = function(){
    event.returnValue = false;
};
    </script>
</body>
</html>